using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace DataLayerTest.Models.Mapping
{
    public class FitbitAccountMap : EntityTypeConfiguration<FitbitAccount>
    {
        public FitbitAccountMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.UserName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Password)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.OwnerID)
                .IsFixedLength()
                .HasMaxLength(6);

            this.Property(t => t.AccessToken)
                .IsFixedLength()
                .HasMaxLength(32);

            this.Property(t => t.AccessSecret)
                .IsFixedLength()
                .HasMaxLength(32);

            // Table & Column Mappings
            this.ToTable("FitbitAccount");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.UserName).HasColumnName("UserName");
            this.Property(t => t.Password).HasColumnName("Password");
            this.Property(t => t.OwnerID).HasColumnName("OwnerID");
            this.Property(t => t.AccessToken).HasColumnName("AccessToken");
            this.Property(t => t.AccessSecret).HasColumnName("AccessSecret");
            this.Property(t => t.IsSubscribed).HasColumnName("IsSubscribed");
            this.Property(t => t.ShouldRemove).HasColumnName("ShouldRemove");
        }
    }
}
